package com.shanghaiyimu.yimiyangche.fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.shanghaiyimu.yimiyangche.R;
import com.shanghaiyimu.yimiyangche.adapter.MyWashListViewItemAdapter;
import com.shanghaiyimu.yimiyangche.bean.ShopBean;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class BanKuaiFragment extends Fragment {


    public BanKuaiFragment() {
        // Required empty public constructor
    }
    private PullToRefreshListView listView;
    private MyWashListViewItemAdapter adapter;
    private List<ShopBean> data = new ArrayList<>();



    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment

        View view = inflater.inflate(R.layout.fragment_ban_kuai, container, false);
        initView(view);
        initData();
        return view;
    }

    private void initData() {
        for (int i = 0; i < 10; i++) {
            ShopBean shopBean = new ShopBean();
            shopBean.setName("上海宜牧"+i);
            shopBean.setPrice("6"+i);
            data.add(shopBean);
        }
        adapter.notifyDataSetChanged();
    }

    private void initView(View view) {
        listView = (PullToRefreshListView) view.findViewById(R.id.fragment_ban_kuai_ptrlistview);
        View head = LayoutInflater.from(getContext()).inflate(R.layout.head_bankuai, null);
        listView.getRefreshableView().addHeaderView(head);
        adapter = new MyWashListViewItemAdapter(getContext(),data);
        listView.setAdapter(adapter);
    }

}
